<?php
class App_Source_Blogs_Validator extends Mozg_Property_Validator
{
	protected function ValidateTitle($value)
	{
		return strlen($value);
	}
	
	protected function ValidateUser($user)
	{
		if (!$user || !$user->GetId()) return true;

		$blog = Mozg_Mapper::Get('Blogs')->GetOne(array('userId' => $user->GetId()));

		if ($blog && ($blog->GetId() != $this->GetData()->GetId()))
        {
            $this->SetErrorMessage('userName', Mozg_Lang::_('SELECTED_USER_HAS_BLOG_ALREADY'));
            $this->AddErrorField('userName');
        }
        
        return true;
	}
}